don't set locale encoding when opening binary file
authorJoey Hess <joeyh@joeyh.name>
Mon, 29 Sep 2025 15:06:18 +0000 (11:06 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 29 Sep 2025 15:06:18 +0000 (11:06 -0400)
importfeed: Fix encoding issues parsing feeds when built with OsPath.

CHANGELOG
Utility/FileIO/CloseOnExec.hs
doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs.mdwn
doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment [new file with mode: 0644]

index d61836f7c7aced8f8a8481b889f94904273f3830..aa63a40a0e06f72f5172344e83ca608f43da7be2 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -4,6 +4,7 @@ git-annex (10.20250926) UNRELEASED; urgency=medium
     annex+http urls and git-annex p2phttp.
   * enableremote: Allow type= to be provided when it does not change the
     type of the special remote.
+  * importfeed: Fix encoding issues parsing feeds when built with OsPath.
 
  -- Joey Hess <id@joeyh.name>  Thu, 25 Sep 2025 13:36:21 -0400
 
index 3d1bb739f74a4c20997e08d218e4c8a8846d144b..1a91add1e7b70dade21a8e7580d880480ba2746c 100644 (file)
@@ -3,9 +3,9 @@
  - All functions have been modified to set the close-on-exec
  - flag to True.
  -
- - Also, functions that return a Handle have been modified to
- - use the locale encoding, working around this bug:
- - https://github.com/haskell/file-io/issues/45
+ - Also, functions that return a Handle (for a non-binary file)
+ - have been modified to use the locale encoding, working around
+ - this bug: https://github.com/haskell/file-io/issues/45
  -
  - Copyright 2025 Joey Hess <id@joeyh.name>
  - Copyright 2024 Julian Ospald
@@ -70,12 +70,12 @@ openFile osfp iomode =  augmentError "openFile" osfp $
 
 withBinaryFile :: OsPath -> IOMode -> (Handle -> IO r) -> IO r
 withBinaryFile osfp iomode act = (augmentError "withBinaryFile" osfp
-    $ withOpenFileEncoding osfp iomode True False closeOnExec (try . act) True)
+    $ withOpenFile' osfp iomode True False closeOnExec (try . act) True)
   >>= either ioError pure
 
 openBinaryFile :: OsPath -> IOMode -> IO Handle
 openBinaryFile osfp iomode = augmentError "openBinaryFile" osfp $
-        withOpenFileEncoding osfp iomode True False closeOnExec pure False
+        withOpenFile' osfp iomode True False closeOnExec pure False
 
 readFile :: OsPath -> IO BSL.ByteString
 readFile fp = withFileNoEncoding' fp ReadMode BSL.hGetContents
index a0ab3871886ed68708636aa35ecf59b58edb8ee3..e6ee11eb868fcc0c5ad93acd6b991ba9ff89054a 100644 (file)
@@ -96,3 +96,5 @@ And it seems a fairly recent breakage, as IIRC the previous installed was from 2
 ### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
 
 Yes, for many years.  git-annex has worked vey well for downloading/collecting podcasts for years, which is why t was surprising it's suddenly failing like this.
+
+> [[fixed|done]] --[[Joey]]
diff --git a/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment b/doc/bugs/importfeed__58___Enum.toEnum__123__Word8__125____58___tag___40__8217__41___is_outs/comment_6_9c6851e659c977eb5106dcd83ea7765a._comment
new file mode 100644 (file)
index 0000000..c11f288
--- /dev/null
@@ -0,0 +1,18 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 6"""
+ date="2025-09-29T14:45:50Z"
+ content="""
+Thanks for some really good detective work @ewen.
+
+Note that this only happens when git-annex is built with the OsPath build
+flag. 
+
+That seems to indicate that the problem is in
+Utility.FileIO.openBinaryFile,
+which is the only way that parseFeedFromFile' varies depending on that
+build flag.
+
+Aha yes, the problem is that uses withOpenFileEncoding, which is
+inappropriate for a binary file!
+"""]]